package mtyan;

import java.util.*;

public class UsersBean {

	public UsersBean(){
		MySQLConnector connector = new MySQLConnector();
		List<List<String>> resultUsers = connector.executeQuery("id, firstname, lastname", 3, "User", null);
		List<User> users = new ArrayList<User>();
		try {
			for (int i=0;i<resultUsers.size();i++){
				List<String> rowUser = resultUsers.get(i);
				User user = new User();
				user.setId(Integer.parseInt(rowUser.get(0)));
				user.setName(rowUser.get(1));
				user.setLastname(rowUser.get(2));
				users.add(user);
			}
			this.users = users;
		} catch (NumberFormatException e) {
			System.out.println("Id of User not integer.");
			e.printStackTrace();
		}
		
	}
	
	public List<User> users;

	public List<User> getUsers() {
		return users;
	}

	public void setUsers(List<User> users) {
		this.users = users;
	} 
	

}
